/*****************************************************************************
 * main_interface.cc : Gtkmmm interface
 ****************************************************************************
 * Copyright © 2006-2008 the VideoLAN team
 *
 * Authors: David Guglielmi <raxxx.fr@gmail.com>
 *          David LARROQUE <snio.fr@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#include <gtkmm/box.h>
#include <gtkmm/main.h> 

#include "main_interface.hh"
#include "components/video_widget.hh"
#include "menus.hh"

MainInterface::MainInterface (intf_thread_t *_p_intf) : p_intf (_p_intf)
{

  ask_for_privacy ();

  set_position (Gtk::WIN_POS_CENTER);
  set_vlc_window_title ();
  
  Gtk::VBox *vbox = new Gtk::VBox ();

  vbox->pack_start (*Gtk::manage (GVLCMenu::create_menu_bar (this, p_intf)), false, false);
  
  p_intf->p_sys->p_video = new VideoWidget (p_intf);
  
  vbox->pack_start (*(p_intf->p_sys->p_video)); 

  add (*Gtk::manage (vbox));

  signal_hide ().connect (sigc::ptr_fun (&Gtk::Main::quit));

}

MainInterface::~MainInterface ()
{

  p_intf->b_interaction = false;
  p_intf->p_sys->p_mi = NULL;
//  p_intf->pf_request_window = NULL;
//  p_intf->pf_release_window = NULL;
//  p_intf->pf_control_window = NULL;

  /* FIXME: Need to be called by dialog_provider */
  vlc_object_kill (p_intf->p_libvlc);

}

inline void
MainInterface::ask_for_privacy ()
{

/* FIXME: Not yet implemented. */

}

void 
MainInterface::set_vlc_window_title (Glib::ustring title)
{

  if (title.empty ())
    set_title (_("VLC media player"));
  else
    set_title (title + " - " + _("VLC media player"));

}

